package com.example.util;

import javax.servlet.http.HttpSession;

public class CodeUtil {
    /**
     * 验证码校验
     * @param request
     * @return
     */
    public static boolean checkVerifyCode(HttpSession session, String key) {
        // 获取生成的验证码
        String verifyCode = (String) session.getAttribute("code");
        System.out.println("verifyCode: " + verifyCode);
        // 获取用户输入的验证码
        if (key == null || !key.equals(verifyCode)) {
            return false;
        }
        return true;
    }
}
